package cn.platform.service;

import cn.platform.entity.Teacher;
import cn.platform.mapper.TeacherMapper;
import cn.platform.request.TeacherRequest;
import cn.platform.response.AResponse;
import cn.platform.response.TeacherOptionVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TeacherService {
    @Resource
    TeacherMapper teacherMapper;

    public AResponse listTeacher(TeacherRequest req) {
        AResponse res = new AResponse();
        if(req.getPageNum() != null && req.getPageSize() != null){
            PageHelper.startPage(req.getPageNum(), req.getPageSize());
        }
        List<Teacher> teachers = teacherMapper.listTeacher(req);
        res.setData(new PageInfo<Teacher>(teachers));
        return res;
    }

    public void insertTeacher(TeacherRequest req) {
        teacherMapper.insertTeacher(req);
    }

//    public List<TeacherOptionVO> getAllTeacherOptions() {
//        return teacherMapper.getAllTeacher();
//    }
    public List<TeacherOptionVO> getAllTeacherOptions() {
        return teacherMapper.getAllTeacher();
    }
}
